#include <stdio.h>
#include <string.h>

#define SIZE 351
#define MAX(a,b) ((a)>(b)?(a):(b))

unsigned short opt[SIZE];

int main (int argc, const char * argv[]) {
	unsigned short N, line, i;
	unsigned short cownum, buffer, update, ans=0;
	scanf("%hu",&N);
	for (line=1; line<=N; line++) {
		for (i=1, buffer=0; i<=line; i++) {
			scanf("%hu",&cownum);
			update = cownum + MAX(opt[i-1], opt[i]);
			opt[i-1]=buffer;
			buffer=update;
		}
		opt[i-1]=buffer;
	}
	for (i=1; i<=N; i++) {
		if (opt[i]>ans) {
			ans=opt[i];
		}
	}
	printf("%hu\n",ans);
    return 0;
}
